var util = {
		options: {
			
			ACTIVE_SRC1: "img/home.png",
			NORMAL_SRC1: "img/home-r.png",
			ACTIVE_SRC2: "img/msg.png",
			NORMAL_SRC2: "img/msg-r.png",
			ACTIVE_SRC3: "img/settings.png",
			NORMAL_SRC3: "img/settings-r.png",
			
			subpages: [{
				url: 'pages/index.html',
				id: 'pages/index.html'
			},
			{
				url: 'pages/totalMsg.html',
				id: 'pages/totalMsg.html'
			},
			{
				url: 'pages/settings.html',
				id: 'pages/settings.html'
			},
			]
		},
		/**
		  *  简单封装了绘制原生view控件的方法
		  *  绘制内容支持font（文本，字体图标）,图片img , 矩形区域rect
		  */
		drawNative: function(id, styles, tags) {
			var view = new plus.nativeObj.View(id, styles, tags);
			return view;
		},
		/**
		  * 初始化首个tab窗口 和 创建子webview窗口
		  */
			initSubpage: function(aniShow) {
				var subpage_style = {
					top: 0,
					bottom: 51
				},
			subpages = util.options.subpages,
			self = plus.webview.currentWebview(),
			temp = {};
			//兼容安卓上添加titleNView 和 设置沉浸式模式会遮盖子webview内容
			if (mui.os.android) {
				if (plus.navigator.isImmersedStatusbar()) {
					subpage_style.top += plus.navigator.getStatusbarHeight();
				}
				if (self.getTitleNView()) {
					subpage_style.top += 40;
				}
			}
	
			// 初始化第一个tab项为首次显示
			temp[self.id] = "true";
			mui.extend(aniShow, temp);
	
			// 初始化绘制首个tab按钮
			util.toggleNview(0);
	
			//预加载所有子页面
			for (var i = 0,
			len = subpages.length; i < len; i++) {
				if (!plus.webview.getWebviewById(subpages[i].id)) {
					var sub = plus.webview.create(subpages[i].url, subpages[i].id, subpage_style);
					//初始化隐藏
					if(i>0)
					sub.hide();
					// append到当前父webview
					self.append(sub);
				}
			}

		},
		/**
		  * 点击切换tab窗口
		  */
		changeSubpage: function(targetPage, activePage, aniShow) {
			
			if(targetPage == activePage){
			  	return;
			}
			
			if (aniShow[targetPage]) {
				plus.webview.show(targetPage);
			} else {
				//否则，使用fade-in动画，且保存变量
				var temp = {};
				temp[targetPage] = "true";
				mui.extend(aniShow, temp);
				plus.webview.show(targetPage, "fade-in", 300);
			}
			//隐藏当前 除了第一个父窗口
			 if(activePage !== plus.webview.getLaunchWebview()) {
				//plus.webview.hide(activePage);
			 }

		},
		/**
		  * 点击重绘底部tab （view控件）
		  */
		toggleNview: function(currIndex) {
			util.updateSubNView(currIndex);
		},
		/*
		  * 利用 plus.nativeObj.View 提供的 drawBitmap 方法更新 view 控件
		  */
		updateSubNView: function(currIndex) {
			var self = plus.webview.currentWebview();
			switch (currIndex){
				case 0:
					__nvbar__.subNViews[0].tags[0].src = "_www/img/home.png";
					__nvbar__.subNViews[0].tags[1].src = "_www/img/msg-r.png";
					__nvbar__.subNViews[0].tags[2].src = "_www/img/settings-r.png";
					__nvbar__.subNViews[0].tags[3].text = __AppBaseInfo.home;
					__nvbar__.subNViews[0].tags[3].textStyles.color = "#FF0000";
					__nvbar__.subNViews[0].tags[4].text = __AppBaseInfo.msg;
					__nvbar__.subNViews[0].tags[4].textStyles.color = "#000000";
					__nvbar__.subNViews[0].tags[5].text = __AppBaseInfo.settings;
					__nvbar__.subNViews[0].tags[5].textStyles.color = "#000000";
					break;
				case 1:
					__nvbar__.subNViews[0].tags[0].src = "_www/img/home-r.png";
					__nvbar__.subNViews[0].tags[1].src = "_www/img/msg.png";
					__nvbar__.subNViews[0].tags[2].src = "_www/img/settings-r.png";
					__nvbar__.subNViews[0].tags[3].text = __AppBaseInfo.home;
					__nvbar__.subNViews[0].tags[3].textStyles.color = "#000000";
					__nvbar__.subNViews[0].tags[4].text = __AppBaseInfo.msg;
					__nvbar__.subNViews[0].tags[4].textStyles.color = "#FF0000";
					__nvbar__.subNViews[0].tags[5].text = __AppBaseInfo.settings;
					__nvbar__.subNViews[0].tags[5].textStyles.color = "#000000";
					break;
				case 2:
					__nvbar__.subNViews[0].tags[0].src = "_www/img/home-r.png";
					__nvbar__.subNViews[0].tags[1].src = "_www/img/msg-r.png";
					__nvbar__.subNViews[0].tags[2].src = "_www/img/settings.png";
					__nvbar__.subNViews[0].tags[3].text = __AppBaseInfo.home;
					__nvbar__.subNViews[0].tags[3].textStyles.color = "#000000";
					__nvbar__.subNViews[0].tags[4].text = __AppBaseInfo.msg;
					__nvbar__.subNViews[0].tags[4].textStyles.color = "#000000";
					__nvbar__.subNViews[0].tags[5].text = __AppBaseInfo.settings;
					__nvbar__.subNViews[0].tags[5].textStyles.color = "#FF0000";
					break;
				default:
					break;
				}
				self.updateSubNViews(__nvbar__.subNViews); 

		}
	};